import {ListStore} from "../listStore";
import * as API from '../../apis/standCustomReport';
import {observable} from "mobx";

export class StandardCustomReportListStore extends ListStore {

    @observable condition = [];

    constructor() {
        super();
        this.loadCondition = this.loadCondition.bind(this);
        this.doSearch = this.doSearch.bind(this);
    }

    loadCondition() {
        API.getReportListCondition({}).then((data = {}) => {
            const {conditions = []} = data;
            this.condition = conditions;
            this.form.initFormFields(conditions);
            this.doSearch();
        });
    }

    doSearch(params = {}) {
        //拼接查询请求参数
        this.loading = true;
        API.getReportList(this.form.getFormParams()).then((data) => {
            this.tableStore.getDatas(data.sessionkey, params.current || 1);
            this.dataKey = data.sessionkey;
            this.loading = false;
        });
    }

}